package windowBuilderExample;

import java.awt.*;
import java.awt.event.*;  
import javax.swing.*; 
public class MyFirstSwing {  
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					MyFirstSwing window = new MyFirstSwing(); 
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	} 
	
	public MyFirstSwing() { 
		JFrame frame = new JFrame();
		frame.setBounds(100, 100, 450, 300);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
		final JButton button = new JButton( "Hello" );
		frame.getContentPane().add( button );
		
		ActionListener listener = new ActionListener() { 
			@Override
			public void actionPerformed(ActionEvent e) {
				if( button.getLabel().equals( "Hello.") ) {
					button.setLabel( "Good Morning." );
				} else {
					button.setLabel( "Hello." );
				}
			}
			
		}; 
		button.addActionListener( listener );
		frame.setVisible(true);  
	}

}
